#!/bin/sh

if [ ! -d /usr/share/capsules/images ] ; then
	mkdir -pv /usr/share/capsules/images
fi

cp -v ../cap.py /sbin/cap
cp -v ../cap-pygtk.py /usr/bin/cap-pygtk
cp -v ../capsules.py /usr/share/capsules/
cp -v fchksum.so /usr/share/capsules/
cp -v ../images/* /usr/share/capsules/images/

if [ "$1" = "track" ] ; then
	if [ -d /var/log/captracks ] ; then
		echo " > Tracking install.sh"
		if [ -d /var/log/captracks/cap_python-* ] ; then
			rm -rvf /var/log/captracks/cap_python-*
		fi
		pkgdate=`date +%Y.%m.%d`
		pkgdir="/var/log/captracks/cap_python-$pkgdate"
		mkdir -pv $pkgdir
		echo "/usr/share/capsules/capsules.py" > $pkgdir/filelist
		echo "/usr/share/capsules/fchksum.so" >> $pkgdir/filelist
		echo "/sbin/cap" >> $pkgdir/filelist
		echo "/usr/bin/cap-pygtk" >> $pkgdir/filelist
		for i in /usr/share/capsules/images/* ; do
			echo "$i" >> $pkgdir/filelist
		done
		echo " ++ Track finished"
	fi
fi

chown root:root -R /usr/share/capsules
chown root:root -R /sbin/cap
chown root:root -R /usr/bin/cap-pygtk